package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.SignatureValidation;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysApply;
import com.ruoyi.project.system.domain.SysMobileUser;
import com.ruoyi.project.system.service.ISysApplyService;
import com.ruoyi.project.system.service.ISysMobileUserService;
import com.ruoyi.project.system.service.ISysTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mobileUser/apply/")
public class UserApplyController {
    @Autowired
    private ISysMobileUserService sysMobileUserService;

    @Autowired
    private ISysApplyService sysApplyService;

    @Autowired
    private ISysTypeService sysTypeService;
    /**
     *   申请入驻工人
     * */
    @PostMapping("applyUser")
    public AjaxResult apply(@RequestBody SysApply sysApply){
        Long mobileUserId = SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId();
        sysApply.setMobileUserId(mobileUserId);
        sysApply.setStatus("0");
        sysApplyService.insertSysApply(sysApply);
        return AjaxResult.success("恭喜你,提交成功............");
    }

    /**
     * 用户端显示服务类型——————
     * */
    @SignatureValidation
    @GetMapping("queryParentList")
    public AjaxResult queryParentList(){
        return AjaxResult.success(sysTypeService.queryParentName());
    }

    /**
     * 用户查看审核是否通过
     * */
    @GetMapping("queryApplyUser")
    public AjaxResult queryApplyUser(SysApply sysApply){
        Long mobileUserId = SecurityUtils.getLoginUser().getSysMobileUser().getMobileUserId();
        sysApply.setMobileUserId(mobileUserId);
        return AjaxResult.success(sysApplyService.queryApplyList(sysApply));
    }

}
